//
//  MSForgetView.m
//  觅尚
//
//  Created by No.8 on 2019/3/19.
//  Copyright © 2019 No.8. All rights reserved.
//

#import "MSForgetView.h"

@implementation MSForgetView


/** 获取验证码按钮*/
- (UIButton *)backButton {
    if (!_backButton) {
        _backButton = [[UIButton alloc] initWithFrame:CGRectMake(40 * px, 100 * px, 80 * px, 100 * px)];
        [_backButton setImage:[UIImage imageNamed:@"左箭头"] forState:UIControlStateNormal];
        [self addSubview:_backButton];
    }
    return _backButton;
}

/** 登录标题*/
- (UILabel *)logintitle {
    if (!_logintitle) {
        _logintitle = [[UILabel alloc] init];
        _logintitle.frame = CGRectMake(150 * px, 300 * px, 280 * px, 70 * px);
        _logintitle.text  = @"忘记密码";
        _logintitle.textColor = [UIColor whiteColor];
        _logintitle.font = [UIFont boldSystemFontOfSize:SYRealValue(38 / 2)];
        [self addSubview:_logintitle];
        
    }
    return _logintitle;
}

/** 手机号输入框*/
- (UITextField *)iphoneTextField{
    if (!_iphoneTextField) {
        _iphoneTextField = [[UITextField alloc] init];
        _iphoneTextField.frame = CGRectMake(self.logintitle.x, CGRectGetMaxY(_logintitle.frame) + 200 * px, (ScreenWidth - _logintitle.x * 2) / 1.5, 150 * px);
        _iphoneTextField.placeholder = @"请输入手机号";
        [_iphoneTextField setValue:[UIColor grayColor] forKeyPath:@"_placeholderLabel.textColor"];
        [_iphoneTextField setValue:[UIFont systemFontOfSize:SYRealValue(35 / 2)] forKeyPath:@"_placeholderLabel.font"];
        _iphoneTextField.keyboardType = UIKeyboardTypeNumberPad;
        _iphoneTextField.textColor = [UIColor whiteColor];
        [self addSubview:_iphoneTextField];
        
    }
    return _iphoneTextField;
    
}

/** 获取验证码按钮*/
- (UIButton *)codeButton {
    if (!_codeButton) {
        _codeButton = [[UIButton alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_iphoneTextField.frame), _iphoneTextField.y, _iphoneTextField.width * 0.5, _iphoneTextField.height)];
        [_codeButton setTitle:@"获取验证码" forState:UIControlStateNormal];
        //        _codeButton.backgroundColor = [UIColor redColor];
        _codeButton.titleLabel.font = [UIFont systemFontOfSize:SYRealValue(35 / 2)];
        [_codeButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [self addSubview:_codeButton];
    }
    return _codeButton;
}


/** 账号下划线*/
- (UIImageView *)iphonelineIMG {
    if (!_iphonelineIMG) {
        _iphonelineIMG = [[UIImageView alloc] initWithFrame:CGRectMake(_iphoneTextField.x, CGRectGetMaxY(_iphoneTextField.frame), ScreenWidth - _logintitle.x * 2, 1)];
        _iphonelineIMG.image = [UIImage imageNamed:@"line"];
        [self addSubview:_iphonelineIMG];
        
    }
    return _iphonelineIMG;
}

/** 验证码输入框*/
- (UITextField *)codeTextField{
    if (!_codeTextField) {
        _codeTextField = [[UITextField alloc] init];
        _codeTextField.frame = CGRectMake(self.logintitle.x, CGRectGetMaxY(_iphonelineIMG.frame) + 80 * px, _iphonelineIMG.width, _iphoneTextField.height);
        _codeTextField.placeholder = @"请输入验证码";
        _codeTextField.keyboardType = UIKeyboardTypeNumberPad;
        [_codeTextField setValue:[UIColor grayColor] forKeyPath:@"_placeholderLabel.textColor"];
        [_codeTextField setValue:[UIFont systemFontOfSize:SYRealValue(35 / 2)] forKeyPath:@"_placeholderLabel.font"];
        _codeTextField.textColor = [UIColor whiteColor];
        [self addSubview:_codeTextField];
        
    }
    return _codeTextField;
    
}


/** 密码下划线*/
- (UIImageView *)codelineIMG {
    if (!_codelineIMG) {
        _codelineIMG = [[UIImageView alloc] initWithFrame:CGRectMake(_iphoneTextField.x, CGRectGetMaxY(_codeTextField.frame), _iphonelineIMG.width, _iphonelineIMG.height)];
        _codelineIMG.image = [UIImage imageNamed:@"line"];
        [self addSubview:_codelineIMG];
        
    }
    return _codelineIMG;
}


/** 新密码输入框*/
- (UITextField *)newpassworldTextField{
    if (!_newpassworldTextField) {
        _newpassworldTextField = [[UITextField alloc] init];
        _newpassworldTextField.frame = CGRectMake(self.logintitle.x, CGRectGetMaxY(_codelineIMG.frame) + 80 * px, _iphonelineIMG.width - 80 * px, _iphoneTextField.height);
        _newpassworldTextField.placeholder = @"请输入新的密码";
        [_newpassworldTextField setValue:[UIColor grayColor] forKeyPath:@"_placeholderLabel.textColor"];
        [_newpassworldTextField setValue:[UIFont systemFontOfSize:SYRealValue(35 / 2)] forKeyPath:@"_placeholderLabel.font"];
        _newpassworldTextField.textColor = [UIColor whiteColor];
        [self addSubview:_newpassworldTextField];
        
    }
    return _newpassworldTextField;
    
}


/** 密码下划线*/
- (UIImageView *)newpassworldlineIMG {
    if (!_newpassworldlineIMG) {
        _newpassworldlineIMG = [[UIImageView alloc] initWithFrame:CGRectMake(_iphoneTextField.x, CGRectGetMaxY(_newpassworldTextField.frame), _iphonelineIMG.width, _iphonelineIMG.height)];
        _newpassworldlineIMG.image = [UIImage imageNamed:@"line"];
        [self addSubview:_newpassworldlineIMG];
        
    }
    return _newpassworldlineIMG;
}

/** 密码可见按钮*/
- (UIButton *)newvisibleButton{
    if (!_newvisibleButton) {
        _newvisibleButton = [[UIButton alloc] init];
        _newvisibleButton.frame = CGRectMake(CGRectGetMaxX(_newpassworldTextField.frame), _newpassworldTextField.y + 35 * px, 80 * px, 80 * px);
        [_newvisibleButton setImage:[UIImage imageNamed:@"可见"] forState:UIControlStateNormal];
        [_newvisibleButton setImage:[UIImage imageNamed:@"不可见"] forState:UIControlStateSelected];
        [self addSubview:_newvisibleButton];
        
    }
    return _newvisibleButton;
    
}



/** 确认新密码输入框*/
- (UITextField *)confirmpassworldTextField{
    if (!_confirmpassworldTextField) {
        _confirmpassworldTextField = [[UITextField alloc] init];
        _confirmpassworldTextField.frame = CGRectMake(self.logintitle.x, CGRectGetMaxY(_newpassworldlineIMG.frame) + 80 * px, _newpassworldlineIMG.width, _iphoneTextField.height);
        _confirmpassworldTextField.placeholder = @"确认密码";
        [_confirmpassworldTextField setValue:[UIColor grayColor] forKeyPath:@"_placeholderLabel.textColor"];
        [_confirmpassworldTextField setValue:[UIFont systemFontOfSize:SYRealValue(35 / 2)] forKeyPath:@"_placeholderLabel.font"];
        _confirmpassworldTextField.textColor = [UIColor whiteColor];
        [self addSubview:_confirmpassworldTextField];
        
    }
    return _confirmpassworldTextField;
    
}


/** 密码下划线*/
- (UIImageView *)confirmlineIMG {
    if (!_confirmlineIMG) {
        _confirmlineIMG = [[UIImageView alloc] initWithFrame:CGRectMake(_iphoneTextField.x, CGRectGetMaxY(_confirmpassworldTextField.frame), _iphonelineIMG.width, _iphonelineIMG.height)];
        _confirmlineIMG.image = [UIImage imageNamed:@"line"];
        [self addSubview:_confirmlineIMG];
        
    }
    return _confirmlineIMG;
}

/** 密码可见按钮*/
- (UIButton *)confirmvisibleButton{
    if (!_confirmvisibleButton) {
        _confirmvisibleButton = [[UIButton alloc] init];
        _confirmvisibleButton.frame = CGRectMake(_newvisibleButton.x, _confirmpassworldTextField.y + 35 * px, _newvisibleButton.width, _newvisibleButton.height);
        [_confirmvisibleButton setImage:[UIImage imageNamed:@"可见"] forState:UIControlStateNormal];
        [_confirmvisibleButton setImage:[UIImage imageNamed:@"不可见"] forState:UIControlStateSelected];
        [self addSubview:_confirmvisibleButton];
        
    }
    return _confirmvisibleButton;
    
}

/** 登录按钮*/
- (UIButton *)loginButton {
    if (!_loginButton) {
        _loginButton = [[UIButton alloc] initWithFrame:CGRectMake(_iphoneTextField.x, CGRectGetMaxY(_confirmlineIMG.frame) + 120 * px, _iphonelineIMG.width, 120 * px)];
        _loginButton.layer.cornerRadius = _loginButton.height * 0.5;
        //        _loginButton.backgroundColor = [UIColor whiteColor];
        [_loginButton setTitle:@"完成" forState:UIControlStateNormal];
        //        _loginButton.frame = CGRectMake(10, 50, 200, 44);
        
        CAGradientLayer *gradientLayer =  [CAGradientLayer layer];
        gradientLayer.frame = _loginButton.bounds;
        gradientLayer.cornerRadius = _loginButton.height * 0.5;
        gradientLayer.startPoint = CGPointMake(0, 0);
        //        gradientLayer
        gradientLayer.endPoint = CGPointMake(1, 0);
        gradientLayer.locations = @[@(0.2),@(1.0)];//渐变点
        [gradientLayer setColors:@[(id)[WYCRGBColor(96, 59, 152) CGColor],(id)[WYCRGBColor(202, 72, 114) CGColor]]];//渐变数组
        [_loginButton.layer addSublayer:gradientLayer];
        _loginButton.titleLabel.font = [UIFont systemFontOfSize:SYRealValue(36 / 2)];
        [self addSubview:_loginButton];
        
    }
    return _loginButton;
}
- (id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        
        //        self.backgroundColor = [UIColor ];
        [self CreateSubView];
    }
    return self;
}
- (void)CreateSubView{
    
    self.backgroundColor = [UIColor whiteColor];
    
    //    [self logintitle];
    
}
@end
